<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>漫画内容添加</title>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>
<div class="container">
    <div class="page-header">添加漫画内容</div>
    <!--设计一个表单，让用户添写信息，并提交到服务器-->
    <form action="addSave.php" method="post" class="form-horizontal" enctype="multipart/form-data">
        <!--作品ID（通过下拉框实现）-->
        <div class="form-group">
            <label for="pro_id" class="col-sm-2 control-label">作品名</label>
            <div class="col-sm-10">

                <?php
                if(isset($_GET["name"])){
                    $name=$_GET["name"];
                    ?>

                    <select class="form-control" name="pro_id" id="pro_id">
                        <option value="<?php include dirname(__FILE__) . '../../common/conn.php';
                        $sqlt = "select * from production where name='$name'";
                        $rest = mysqli_query($con, $sqlt);
                        mysqli_close($con);
                        $rowt=mysqli_fetch_array($rest,1);
                        if($rowt)
                            echo $rowt["id"];
                        else
                            echo ""; ?>" selected="selected" readonly="true"> <?php echo $name ?></option>
                    </select>

                    <?php
                }
                else {?>
                <select class="form-control" name="pro_id" id="pro_id">

                    <?php
                    //查询出数据库中所有的漫画
                    include dirname(__FILE__) . '../../common/conn.php';
                    $sql = "select * from production";
                    $res = mysqli_query($con, $sql);
                    mysqli_close($con);

                    while ($row = mysqli_fetch_array($res)) {
                        ?>
                        <option value="<?php echo $row["id"] ?>"><?php echo $row["name"] ?></option>
                    <?php }
                    }
                    ?>
                </select>
            </div>
        </div>

        <!--章节序号-->
        <div class="form-group">
            <label for="csection" class="col-sm-2 control-label">章节序号</label>
            <div class="col-sm-10">
                <input type="int" class="form-control" name="csection" id="csection" placeholder="请输入章节序号（例：1）">
            </div>
        </div>
        <!--章节封面图片-->
        <div class="form-group">
            <label for="section_Img" class="col-sm-2 control-label">章节封面图</label>
            <div class="col-sm-10">
                <input type="file" class="form-control" name="section_Img">
            </div>
        </div>
        <!--章节名称-->
        <div class="form-group">
            <label for="section_Name" class="col-sm-2 control-label">章节名称</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="section_Name" id="section_Name" placeholder="请输入章节名称">
            </div>
        </div>
        <!--章节内容图片-->
        <div class="form-group">
            <label for="img_Url" class="col-sm-2 control-label">章节内容图</label>
            <div class="col-sm-10">
                <input type="file" class="form-control" name="img_Url">
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">添加</button>
                <a href="cList.php" class="btn btn-danger">返回</a>
            </div>
        </div>
    </form>
</div>
</body>
</html>